import sys

def main():
    lines = sys.stdin.readlines()
    lines.sort(key = lambda x : x.split()[0])
    sys.stdout.writelines(lines)

if __name__ == '__main__':
    main()
